<%-- 
    Document   : AsignarEncargado
    Created on : 16/07/2008, 12:44:42 PM
    Author     : Alejandro
--%>

<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page language="java" import="com.akcess.vo.*" %>
<%@ page language="java" import="manejadores.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
            String path = request.getContextPath();
            String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
    <!--  Version: Multiflex-3.12 / Overview                    --><!--  Date:    January 20, 2008                             --><!--  Design:  www.1234.info                                --><!--  License: Fully open source without restrictions.      --><!--           Please keep footer credits with the words    --><!--           "Design by 1234.info" Thank you!             -->
    <script language="JavaScript">
        <!--
        function aviso(nombre,idSala,idEncargado,turno,nombreRecurso){
            if(confirm("¿Esta seguro que desea BORRAR el Encargado: " + nombre+"?"))
                parent.location="GestionarRecurso_Sala_de_Maquinas?hacer=opBorrarEncargado&id=" + idSala +"&nombreRecurso=" + nombreRecurso + "&idEncargado=" + idEncargado + "&turno=" + turno;
        }
            
        -->
            
    </script>  
    
    
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="3600">
    <meta name="revisit-after" content="2 days">
    <meta name="robots" content="index,follow">
    <meta name="publisher" content="Your publisher infos here ...">
    <meta name="copyright" content="Your copyright infos here ...">
    <meta name="author" content="Design: 1234.info / Modified: Your Name">
    <meta name="distribution" content="global">
    <meta name="description" content="Your page description here ...">
    <meta name="keywords" content="Your keywords, keywords, keywords, here ...">
    <base href="<%=basePath%>">
    <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_setup.css">
    <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_text.css">
<link rel="icon" type="image/x-icon" href="./img/favicon.ico"><title>SRR - Sistema de Reserva de Recursos</title><!-- Global IE fix to avoid layout crash when single word size wider than column width --><!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]--><link href="./css/highlighter.css" type="text/css" rel="stylesheet"><link href="./css/highlighter_002.css" type="text/css" rel="stylesheet"></head><body>
<!-- Main Page Container -->
<div class="page-container">
    
    <!-- For alternative headers START PASTE here -->

    <!-- A. HEADER -->      
           <jsp:include page="../Header.jsp"/>
            
            <!-- For alternative headers END PASTE here -->

    <!-- B. MAIN -->
    <div class="main">
        
        <!-- B.1 MAIN NAVIGATION -->
                <jsp:include page="../barraOperaciones.jsp"/>            
        <!-- B.2 MAIN CONTENT -->
        <div class="main-content">                    
            <!-- Pagetitle -->                    
                            <%
                            String nombreRecurso = request.getParameter("nombreRecurso");
            out.println("<h1 class=\"pagetitle\"> Asignar Encargado a " + nombreRecurso + "</h1>");
            Connection cone;
            cone = (Connection) session.getAttribute("conexion");
            int idRecurso = Integer.parseInt(request.getParameter("id"));
            ManejadorSM manejador = new ManejadorSM(cone);
            Tiene_encargados[] encargados = manejador.ObtenerEncargados(idRecurso);


            out.println("<table border=\"0\">");
            out.println("<tbody>");
            out.println("<tr>");
            out.println("<th class=\"top\"><center>Nombre</center></th>");
            out.println("<th class=\"top\"><center>Apellido</center></th>");
            out.println("<th class=\"top\"><center>Turno</center></th>");
            out.println("</tr>");

            for (int i = 0; i < encargados.length; i++) {
                out.println("<tr>");
                if (encargados[i].getNombre() != null) {
                    out.println("<td aling=\"center\">" + encargados[i].getNombre() + "</td>");
                } else {
                    out.println("<td aling=\"center\">No tiene</td>");
                }

                if (encargados[i].getApellido() != null) {
                    out.println("<td aling=\"center\">" + encargados[i].getApellido() + "</td>");
                } else {
                    out.println("<td aling=\"center\">No tiene</td>");
                }

                if (encargados[i].getTurno().equals("M")) {
                    out.println("<td aling=\"center\">Mañana</td>");
                }
                if (encargados[i].getTurno().equals("T")) {
                    out.println("<td aling=\"center\">Tarde</td>");
                }
                if (encargados[i].getTurno().equals("N")) {
                    out.println("<td aling=\"center\">Noche</td>");
                }
                out.println("<th class=\"nada\"><a href=\"javascript:aviso(" + "\'" + encargados[i].getNombre() + "\'" + "," + "\'" + encargados[i].getId_sala() + "\'" + "," + "\'" + encargados[i].getId_encargado() + "\'" + "," + "\'" + encargados[i].getTurno() + "\'" +"," + "\'" + nombreRecurso + "\'"+");\">Borrar</a></th>");

                out.println("</tr>");
            }
                                %>
            <tr> 
                <%
            String error = (String) request.getAttribute("Error");
            if (error != null) {
                out.println("<br><p><FONT FACE=\"arial\" SIZE=1 COLOR=red>" + error + "</FONT></p>");
            }
                %>
            </tr>       
            </tbody>
            </table>  
            <%
            out.println("<form name=\"crear\" action=\"GestionarRecurso_Sala_de_Maquinas?hacer=opAsignarEncargado&id=" + idRecurso + "&nombreRecurso=" +nombreRecurso+"\" method=\"post\">");
            %>
            <table border="1">
                <tbody>
                    <tr>
                        <th class="top"><center>Encargado</center></th>
                        <th class="top"><center>Turno</center></th>
                    </tr>
                    <tr>                                  
                        <%
            ManejadorRecursosHumanos manejadorHumano = new ManejadorRecursosHumanos(cone);
            RecursoHumanoCompleto[] humanos = manejadorHumano.ListarRecursosHumanos();

            //Select para seleccionar el encargado.
            out.println("<td><center><select name=\"Encargado\">");
            out.println("<option value=\"\">[Seleccione Encargado]</option>");
            for (int j = 0; j < humanos.length; j++) {
                if (!humanos[j].getBorrado() && humanos[j].getDisponible()) {
                    out.println("<option value=" + humanos[j].getId_recurso() + "> " + humanos[j].getNombre() + " " + humanos[j].getApellido());
                }
            }
            out.println("</select></center></td>");

            //Select para seleccionar la ubicacion.                        
            out.println("<td><center><select name=\"Turno\">");
            out.println("<option value=\"\">[Seleccione Turno]</option>");
            out.println("<option value=\"M\">Mañana</option>");
            out.println("<option value=\"T\">Tarde</option>");
            out.println("<option value=\"N\">Noche</option>");
            out.println("</select></center></td>");

                        %>                                                                  
                    </tr>
                    <tr>
                        <td colspan="2"><center><input type="submit" name="btnGuardar" value="Asignar"></center></td>
                    </tr> 
                </tbody>    
            </table>
            </form>
        </div>                
        <!-- B.3 SUBCONTENT -->                
    </div>            
    <!-- C. FOOTER AREA -->   
           <%@include file="../footer.jsp"%>   
</div>         
</body>
</html>
